<%@ page language="java" import="weaver.conn.RecordSet" pageEncoding="UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>

<%
    JSONObject jsonData = new JSONObject();
    JSONArray specialobj = new JSONArray();

    RecordSet rs = new RecordSet();
    String bq = Util.null2String( request.getParameter( "bq" ) );
    String dq = Util.null2String( request.getParameter( "dq" ) );
    //获取今日中间表数据的sql
    String sqlwhere = "select id,khmc from uf_khk where 1=1";
    if (StringUtils.isNotBlank( dq )) {
        sqlwhere += " and dq = '" + dq + "'";
        if (StringUtils.isNotBlank( bq )) {
            String [] arr = bq.split(",");
            for (int i =0;i<arr.length;i++) {
                if(i==0){
                    sqlwhere += " or modelableid like '%"+arr[i]+"%'";
                }else {
                    sqlwhere += " or modelableid like '%"+arr[i]+"%'";
                }

            }
        }
    }else {
        if (StringUtils.isNotBlank( bq )) {
            String [] arr = bq.split(",");
            for (int i =0;i<arr.length;i++) {
                if(i==0){
                    sqlwhere += " and modelableid like '%"+arr[i]+"%'";
                }else {
                    sqlwhere += " or modelableid like '%"+arr[i]+"%'";
                }

            }
        }
    }

    rs.executeQuery( sqlwhere );
    String value = "";
    while (rs.next()) {
        JSONObject json = new JSONObject();
        String id = Util.null2String( rs.getString( "id" ) );
        String khmc = Util.null2String( rs.getString( "khmc" ) );
        value += "".equals( value ) ? id : "," + id;
        json.put( "id", id );
        json.put( "name", khmc );
        specialobj.add( json );
    }
    jsonData.put( "specialobj", specialobj );
    jsonData.put( "value", value );
    out.print( jsonData.toJSONString() );
%>
